package visualgeditor.editor;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider;

/**
 * classe que define o particionamento do documento
 *
 */
public class VisualgDocumentProvider extends FileDocumentProvider {

	protected IDocument createDocument(Object element) throws CoreException {
		IDocument document = super.createDocument(element);
		if (document != null) {
			IDocumentPartitioner partitioner =
				new FastPartitioner(
					new VisualgPartitionScanner(),
					new String[] {
						VisualgPartitionScanner.VISUALG_COMMENT,
						VisualgPartitionScanner.VISUALG_ALGORITHM,
						VisualgPartitionScanner.VISUALG_FUNCTION,
						VisualgPartitionScanner.VISUALG_PROCEDURE});
			partitioner.connect(document);
			document.setDocumentPartitioner(partitioner);
		}
		System.out.println("Fui criado!");
		return document;
	}
}